<?php

namespace Home\Controller;

use Common\Controller\HomeBaseController;

class FangweiController extends HomeBaseController {
	function _initialize() {
		parent::_initialize ();
		

		 $this->assign ( "nav", "home" );
		
	}
	public function index() {


		
		cookie("jump_self",get_now_url());


		$id=I("get.id");

		$_data=D("Qrcode")->where(array("id"=>$id))->find();






		if(!$this->u&&$_data["j_id"]){


			$data=array(
				"open_id"=>session("open_id"),
				"inputtime"=>time(),
				"j_id"=>$_data["j_id"],
			);


			$g=M("GuanLog")->where(array("open_id"=>session("openid")))->count();

			if(!$g){

				M("GuanLog")->add($data);
			}






		}



		$d=array(
			"code_id"=>$id,
			"open_id"=>session("open_id"),
			"datetime"=>time(),
			"address"=>$_data["address"],

		);

		if(session("open_id")){

		D("QrcodeLog")->add($d);

		M("Qrcode")->where(array("id"=>$id))->setInc("views");
		}

		if($_data["goumairen"]){
			$this->assign ( "seo_title", "作品信息" );
		}else{
			$this->assign ( "seo_title", "防伪查询" );
		}


		if($_data[product_id]){


			session("j_id",$_data["j_id"]);
			$this->redirect(U('Product/show',array("id"=>$_data["product_id"],"q_id"=>$id)));
		}



		$s=D("Product")->where(array("id"=>$id))->find();
		$_data["author"]=$s["author"];
		$_data["dengji"]=$s["dengji"];
		$_data["title"]=$s["title"];


		$this->assign("_data",$_data);




		$this->assign ( "seo_keywords", C ( "SITE_KEYWORDS" ) );
		$this->assign ( "seo_description", C ( "SITE_DESCRIPTION" ) );
		$this->display ( "" );
	}
	

 

}